//
//  Configure OttoMate Workflow.m
//  Configure OttoMate Workflow
//
//  Created by itod on 4/1/07.
//  Copyright 2007 Todd Ditchendorf. All rights reserved.
//

#import "Configure OttoMate Workflow.h"


@implementation Configure_OttoMate_Workflow

#pragma mark -
#pragma mark AMBundle

- (void)opened
{
	[[self parameters] setObject:[OttoMateAction delay] forKey:@"delay"];
}


- (id)runWithInput:(id)input fromAction:(AMAction *)anAction error:(NSDictionary **)errorInfo
{
	[self checkParametersForInputVariable];
	
	[OttoMateAction setDelay:[self objectForParameterKey:@"delay"]];
	[OttoMateAction setErrorHandlerScriptPath:[self objectForParameterKey:@"errorHandlerScriptPath"]];
	[OttoMateAction setAssertionFailedScriptPath:[self objectForParameterKey:@"assertionFailedScriptPath"]];
	return input;
}


#pragma mark -
#pragma mark Actions

- (IBAction)browse:(id)sender
{	
	NSOpenPanel *openPanel = [NSOpenPanel openPanel];
	int result = [openPanel runModalForDirectory:nil file:nil types:nil];
	
	if (NSOKButton == result) {
		NSString *key = ([sender tag]) ? @"assertionFailedScriptPath" : @"errorHandlerScriptPath";
		[[self parameters] setObject:[openPanel filename] forKey:key];
	}
}

@end
